package org.rqb.panel;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;


public class GesturePanel extends JPanel {

    private final List<Point> points = new ArrayList<>();

    public void addPoint(Point p) {
        points.add(p);
    }

    public void clear() {
        points.clear();
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        g2.setColor(new Color(239, 110, 110));
        g2.setStroke(new BasicStroke(3f));
        for (int i = 1; i < points.size(); i++) {
            Point p1 = points.get(i-1), p2 = points.get(i);
            g2.drawLine(p1.x, p1.y, p2.x, p2.y);
        }
    }
}
